﻿using AiXiu.BLL;
using AiXiu.Common;
using AiXiu.IBLL;
using AiXiu.Model;
using System;

namespace AiXiu.Web
{
    public partial class AvatarEdit : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnAvatar_Click(object sender, EventArgs e)
        {
            //读取用户资料 
            TBUsers tBUsers = IdentityManager.ReadUser();
            tBUsers.Avatar = hfAvatar.Value;
            IdentityManager.SaveUser(tBUsers);
            //更新资料
            IUserManager iuserManager = new UserManager();
            OperResult<TBUsers> operResult = iuserManager.EditAvatar(tBUsers);
            if (operResult.StatusCode == StatusCode.Succeed)
            {
                //更新缓存用户资料
                IdentityManager.SaveUser(operResult.Result);
                //跳转个人页面
                Response.Redirect("Personal.aspx");
            }
            else
            {
                this.Alert("editerror", operResult.Message);
            }
        }
    }
}